import {onMounted, onUnmounted, ref} from "vue";

const scroll = (isScroll) => {
    const top = ref(0)

     onMounted(() => {
         window.addEventListener("scroll", scrolling)
     })

    onUnmounted(() => {
        window,addEventListener("scroll", scrolling)
    })

     const scrolling = () => {
         let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop

         let scrollStep = scrollTop - top.value

         top.value = scrollTop

         if (scrollStep < 0) {
             isScroll.value = true
         } else {
             isScroll.value = false
         }
     }
 }

 export default scroll